home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / wink2 / src / video.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-26  |  2.4 KB  |  160 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <egb.h>
  4.  
  5. extern    char    *work;
  6.  
  7.  
  8. //    47a    VC3 regs指定
  9. //    47c    VC3 regsデータ内容指定
  10.  
  11. //    VC3 regs
  12. //        2000    色数
  13. //        2010    ビデオ表示開始/表示状態取得/表示フィールド/指定
  14. //        2011    表示倍率指定
  15. //        2027    ソースビデオ映像のx1
  16. //        2028    ソースビデオ映像のx2
  17. //        2029    ソースビデオ映像のy1
  18. //        202a    ソースビデオ映像のy2
  19. //        202b    表示開始位置のx
  20. //        202c    表示開始位置のy
  21. //        202d    vramオフセット(1ラインのバイト数)
  22. //
  23.  
  24. void videoSet()
  25. {
  26.     int    i;
  27.     outpw(0x47a,0);
  28.     outp(0x47d,2);
  29.  
  30.     outpw(0x47a,0x2000);
  31.     outp(0x47c,1);
  32.     i = inp(0x47c) & 0x80;
  33.  
  34.     outp(0x47d,0x11);
  35.     outp(0x47f,9);
  36.  
  37.     outpw(0x47a,0x2010);
  38.     i = inp(0x47c) & 0x7f;
  39.     outp(0x47c,i);
  40.     outp(0x47c,0);
  41.     outp(0x47c,0x80);
  42.     outp(0x47f,0);
  43.  
  44.     /* 表示モード設定 */
  45.  
  46.     outp(0x47e,4);
  47.  
  48.  
  49.     outpw(0x47a,0x2011);
  50.     outp(0x47f,9);
  51.  
  52.     outp(0x47c,0);
  53.     outp(0x47d,0x80);
  54.  
  55.     outpw(0x47a,0x2020);
  56.     outpw(0x47c,0xfb4);
  57.  
  58.     outpw(0x47a,0x2022);
  59.     outpw(0x47c,0x137);
  60.  
  61.     outpw(0x47a,0x2023);
  62.     outpw(0x47c,0x7ff);
  63.  
  64.     outpw(0x47a,0x2024);
  65.     outpw(0x47c,0xfef);
  66.  
  67.     outpw(0x47a,0x2026);
  68.     outpw(0x47c,0x7ff);
  69.  
  70.     outpw(0x47a,0x2027);
  71.     outpw(0x47c,0);
  72.  
  73.     outpw(0x47a,0x2028);
  74.     outpw(0x47c,0x27f);
  75.     
  76.     outpw(0x47a,0x2029);
  77.     outpw(0x47c,0);
  78.  
  79.     outpw(0x47a,0x202a);
  80.     outpw(0x47c,0xef);
  81.  
  82.     outpw(0x47a,0x202b);
  83.     outpw(0x47c,0x60*2);
  84.  
  85.     outpw(0x47a,0x202c);
  86.     outpw(0x47c,0);
  87.  
  88.     outpw(0x47a,0x202d);
  89.     outpw(0x47c,0x200);
  90.  
  91.     outpw(0x47a,0x2010);
  92.     i = inp(0x47e) | 1;
  93.     outp(0x47e,i);
  94.  
  95. }
  96.  
  97. int vc3_check()
  98. {
  99.     int    i;
  100.  
  101.     i = inp(0x479) & 0x40;
  102.     if (i!=0) return 1;
  103.  
  104.     outpw(0x47A,0x2000);
  105.     i = inp(0x47c) & 1;
  106.     if (i!=1) return 1;
  107.  
  108.     outpw(0x50a0,4);
  109.     i = inp(0x50a2) & 0x80;
  110.     if (i!=0) return 1;
  111.  
  112.     return 0;
  113. }
  114. int VC3_check2()
  115. {
  116.     int    i;
  117.  
  118.     outpw(0x47A,0x2010);
  119.     i = inp(0x47E) & 1;
  120.     return i;
  121. }
  122.  
  123. void reset_VC3()
  124. {
  125.     int    i;
  126.  
  127.     outpw(0x47A,0x2010);
  128.     outp(0x47F,2);
  129.  
  130.     i=0;
  131.     while(i<1000000 && ((inp(0x47E) & 1) != 0)) i++;
  132.  
  133.     outp(0x47F,0);
  134.     outpw(0x47A,0x2000);
  135.     outp(0x47C,1);
  136. }
  137.  
  138. int    video_flg;
  139. void VC_on()
  140. {
  141.     if (vc3_check()) return;
  142.     if (VC3_check2()) reset_VC3();
  143.  
  144.     EGB_writePage(work,1);
  145.     EGB_displayStart(work,0,512,32);
  146.     videoSet();
  147.     EGB_writePage(work,0);
  148.     video_flg = 1;
  149. }
  150. void VC_off()
  151. {
  152.     if (VC3_check2()) reset_VC3();
  153.     EGB_writePage(work,1);
  154.     EGB_color(work,1,0);
  155.     EGB_clearScreen(work);
  156.     EGB_writePage(work,0);
  157.     video_flg = 0;
  158. }
  159.  
  160.